﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HitPoint : MonoBehaviour
{

    public float damage = 1;
    public bool BigGuy;
    public bool BaldPirate;
    public bool Cucumber;
    public bool Captain;
    public bool Whale;

    private int direction;


    public void OnTriggerEnter2D(Collider2D other){
        if(other.CompareTag("Player")){
            other.GetComponent<IDamageble>().GetHit(damage);
        }
        if(other.CompareTag("Bomb")){
            if(BaldPirate){
                if(transform.position.x - other.transform.position.x > 0){  //小于0在 右边，大于0 在左边
                    direction = -1;
                }else{
                    direction = 1;
                }
                other.GetComponent<Rigidbody2D>().AddForce(new Vector2(direction,1) * 10, ForceMode2D.Impulse);
            }
        }
    }
}
